import 'package:flutter/material.dart';
import 'dart:math';

import 'package:flutter/services.dart';

class NativePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return NativePageState();
  }
}

class NativePageState extends State<NativePage> {
  Color _randomColor() {
    var red = Random.secure().nextInt(255);
    var greed = Random.secure().nextInt(255);
    var blue = Random.secure().nextInt(255);
    return Color.fromARGB(255, red, greed, blue);
  }

  @override
  void initState() {
    super.initState();
  }

  static const jumpPlugin = const MethodChannel('zzy_test_plugin');

  Future<Null> _jumpToNative() async {
    String result = await jumpPlugin.invokeMethod('oneAct');

    print(result);
  }

  Future<Null> _jumpToNativeWithValue() async {
    Map<String, String> map = {"flutter": "这是一条来自flutter的参数"};

    String result = await jumpPlugin.invokeMethod('twoAct', map);

    print(result);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Native Example"),
      ),
      body: ListView(
        children: <Widget>[
          FlatButton(
            child: Text("toNative"),
            onPressed: () {},
          )
        ],
      ),
    );
  }
}
